﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using MusicStore.WebMVC.Models;

namespace MusicStore.WebMVC.Controllers
{
    public class HomeController : BaseController
    {
        //
        // GET: /Home/

        public ViewResult Index()
        {
            return View(GetTopSellingAlbums(5));
        }

        List<Album> GetTopSellingAlbums(int count)
        {
            // Group the order details by album and return 
            // the albums with the highest count 
            return db.Albums.OrderByDescending(a => a.OrderDetails.Count).Take(count).ToList();
        }
    }
}